<template>
	<view class="record-page">
	    <scroll-view 
	      class="record-list"
	      scroll-y
	      :show-scrollbar="false"
	    >
	      <view 
	        v-for="(record, index) in recordList" 
	        :key="index"
	        class="record-item"
	      >
	        <view class="time">{{record.createdAt }}</view>
	        <view class="address">{{ record.startingLocation }}</view>
	      </view>
	    </scroll-view>
	  </view>
</template>

<script setup>
	
	import { ref,onMounted } from 'vue';
	import request from'@/utils/request.js'
	
	const recordList = ref([]);
	


	function getshops(){
		console.log("调用查找商家")
		request({
			url:"/gmh/emergencyRescueRecords/getNearbyBusiness?longitude=113.61332&latitude=34.74821&radius=100000",
			method:'get'
		}).then(res=>{
			console.log(res)
		}).catch(err=>{
			console.log("报错",err)
		})
	}
	
	onMounted(() => {

		addAidLog();
		getshops();
	})
	
	const userId=ref(1)
	function addAidLog(){
		console.log("走函数")
		request({
			url:"/gmh/emergencyRescueRecords/getUserInfo?userId=1",
			method:'get'
		}).then(res=>{
			console.log(res)
			recordList.value=res
			console.log(recordList.value)
		}).catch(err=>{
			console.log("报错",err)
		})
		
		
	}
	
	
	
	
	// 时间格式化方法
	// const formatTime = (isoString) => {
	//   const date = new Date(isoString);
	  
	//   // 日期时间格式化
	//   const year = date.getFullYear();
	//   const month = padZero(date.getMonth() + 1);
	//   const day = padZero(date.getDate());
	//   const hours = padZero(date.getHours());
	//   const minutes = padZero(date.getMinutes());
	
	//   return `${year}-${month}-${day} ${hours}:${minutes}`;
	// };
	
	// // 补零函数保持不变
	// const padZero = (n) => n.toString().padStart(2, '0');
</script>

<style lang="scss" scoped>
	       /* 样式保持原样 */
	       .record-page {
	         padding: 20rpx 30rpx;
	         background-color: #f5f5f5;
	       }
	       
	       .record-list {
	         height: 100vh;
	       }
	       
	       .record-item {
	         padding: 24rpx;
	         margin-bottom: 20rpx;
	         background: #ffffff;
	         border-radius: 16rpx;
	         box-shadow: 0 4rpx 12rpx rgba(0,0,0,0.05);
	       
	         &:last-child {
	           margin-bottom: 0;
	         }
	       
	         .time {
	           font-size: 24rpx;
	           color: #999;
	           line-height: 1.4;
	           margin-bottom: 12rpx;
	         }
	       
	         .address {
	           font-size: 32rpx;
	           color: #333;
	           line-height: 1.5;
	           font-weight: 500;
	         }
	       }
</style>
